from django.contrib import admin

# Register your models here.

#导入表的类名
from user.models import *


"""制定部门类在后台要显示的属性"""
class DepartmentAdmin(admin.ModelAdmin):
    #指定要显示的属性,不指定就默认显示名字
    list_display = ['id','name']
    #定义一页显示多少条数据,默认为100条
    list_per_page = 5
    #显示或隐藏操作栏,默认为显示
    # actions_on_top = True
    # actions_on_bottom = True
    #显示过滤栏，默认为不显示的，指定按哪些属性过滤
    list_filter = ['is_delete']
    #显示搜索栏,按哪些属性搜索
    search_fields = ['name']


class EmployeeAdmin(admin.ModelAdmin):
    #指定要显示的属性,不指定就默认显示名字
    list_display = ['id','name','age','gender','comment','department','avatar']
    # 定义一页显示多少条数据,默认为100条
    list_per_page = 10
    # 显示或隐藏操作栏,默认为显示
    # actions_on_top = True
    # actions_on_bottom = True
    # 显示过滤栏，默认为不显示的，指定按哪些属性过滤
    list_filter = ['gender',"department",]
    # 显示搜索栏,按哪些属性搜索
    search_fields = ['name','age','department']
    #后台添加信息的时候显示的字段
    fieldsets = (('基本',{'fields':('name','age','gender','salary')}),('高级',{'fields':('comment','department','avatar')}))



#注册Model类(部门表类和员工表类)，还要注册后台属性显示表
admin.site.register(Department,DepartmentAdmin)
admin.site.register(Employee,EmployeeAdmin)


#修改后台标题信息
admin.site.site_title = '逗爷最帅框架'
admin.site.site_header = '逗爷最帅系统'
admin.site.index_title = '欢迎来夸逗爷最帅'
